package com.foreknow.demo4;
/**
 * Created by foreknow on 2022/5/15.
 * 1. 定义一个类Point,包含两个变量x , y分别表示坐标，定义两个构造器 Point()  Point(int x,int y)
 * 以及定义一个movePoint(int x,int y) 方法来实现点的位置的移动。创建两Point对象 p1, p2 分别调用
 * movePoint方法后，打印p1  p2的坐标
 * */
public class Point {
    private int x;
    private int y;
    public Point(){
        this.x = 0;
        this.y = 0;
    }
    public Point(int x,int y){
        this.x = x;
        this.y = y;
    }
    public void movePoint(int x,int y){
        this.x = this.x + x;
        this.y = this.y + y;
    }
    public static void main(String[] args) {
        Point p1 = new Point();
        Point p2 = new Point(10,15);
        p1.movePoint(20,30);
        p2.movePoint(4,5);
        System.out.println("("+p1.x+","+p1.y+")");
        System.out.println("("+p2.x+","+p2.y+")");
    }
}
